<template>
	<!-- financialmanagement财务管理 -->
	<view class="f_wp">
		<view class="f_sz">
			<view class="f_money">
				<view>总收入：</view>
				<view class="f_rmb">
					<view class="">
						<text>{{info.total.in.money}}</text>元
					</view>
					<view class="f_bk">
						<text>{{info.total.in.credit1}}</text>米币
					</view>
				</view>
			</view>
			<view class="f_money">
				<view>总支出：</view>
				<view class="f_rmb">
					<view class="">
						<text>{{info.total.out.money}}</text>元
					</view>
					<view class="f_bk">
						<text>{{info.total.out.credit1}}</text>米币
					</view>
				</view>
			</view>
		</view>
		<radio-group class="f_radio_group" @change="radioChange">
			<view class="f_item">
				<radio class="f_radio" checked color="#8405dc" value="1" />
				<view class="">今日</view>
			</view>
			<view class="f_item">
				<radio class="f_radio" color="#8405dc" value="2" />
				<view class="">本周</view>
			</view>
			<view class="f_item">
				<radio class="f_radio" color="#8405dc" value="3" />
				<view class="">本月</view>
			</view>
			<view class="f_item">
				<radio class="f_radio" color="#8405dc" value="4" />
				<uni-datetime-picker v-model="datetimerange" type="datetimerange" rangeSeparator="至" />
			</view>
		</radio-group>
		<view class="fbt" @click="getInfo">查询</view>
		<view class="f_list">
			<view class="f_l_item" v-for="(item,index) in info.list" :key="index"
				@click="$navTo('/pages/groupmenu/financialdetails?uid='+item.info.uid+'&type='+type+'&begintime='+parseInt(datetimerange[0] / 1000)+'&endtime='+parseInt(datetimerange[1] / 1000))">
				<image :src="item.info.logo" mode=""></image>
				<view class="f_l_info">
					<view class="clamp">{{item.info.title}}</view>
					<view class="f_money f_l_money">
						<view>收入：</view>
						<view class="f_rmb">
							<view class="">
								<text>{{item.in.money}}</text>元
							</view>
							<view class="f_bk">
								<text>{{item.in.credit1}}</text>米币
							</view>
						</view>
					</view>
					<view class="f_money f_l_money">
						<view>支出：</view>
						<view class="f_rmb">
							<view class="">
								<text>{{item.out.money}}</text>元
							</view>
							<view class="f_bk">
								<text>{{item.out.credit1}}</text>米币
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: 1,
				info: {
					list: [],
					total: {
						in: {},
						out: {}
					}
				},
				datetimerange: ['', ''],
			}
		},
		onLoad() {
			this.getInfo();
		},
		methods: {
			getInfo() {
				let obj = {
					type: this.type,
					begintime: this.datetimerange[0],
					endtime: this.datetimerange[1]
				}
				obj.begintime = Date.parse(obj.begintime) ? Date.parse(obj.begintime) : obj.begintime;
				obj.endtime = Date.parse(obj.endtime) ? Date.parse(obj.endtime) : obj.endtime;
				obj.begintime = parseInt(obj.begintime / 1000);
				obj.endtime = parseInt(obj.endtime / 1000);
				this.$axios('groupMoney/query', 'POST', 'supplier', obj).then(res => {
					if (res.data.code == 200) {
						this.info = res.data.data;
					}
				})
			},
			radioChange(e) {
				this.type = e.detail.value;
			}
		}
	}
</script>

<style lang="scss">
	page {
		color: $font-color-dark;
		padding-bottom: 120upx;
	}

	.f_sz,
	.f_money {
		background-color: #fff;
		padding: 20upx;
	}

	.f_money {
		padding: 20upx 0;
	}

	.f_money,
	.f_rmb {
		display: flex;
		align-items: center;
	}

	.f_rmb {
		flex: 1;
	}

	.f_rmb view {
		flex: 1;
	}

	.f_rmb text {
		color: #0062CC;
		flex: 1;
	}

	.f_rmb text:nth-of-type(2) {
		margin-left: 20upx;
	}

	.f_bk {
		text-align: right;
	}

	.f_radio_group {
		padding: 0 20upx;
	}

	.f_item {
		display: flex;
		align-items: center;
		padding: 10upx 0;
	}

	.f_radio {
		transform: scale(0.8);
		margin-right: 10upx;
	}

	.f_l_item {
		border-top: 1px hsl(0, 0%, 87%) solid;
		display: flex;
		align-items: center;
		padding: 20upx;
	}

	.f_l_item image {
		border-radius: 10upx;
		height: 120upx;
		width: 120upx;
	}

	.f_l_info {
		padding: 0 20upx;
		width: calc(100% - 120upx);
		line-height: 40upx;
	}

	.f_l_money {
		padding: 0;
	}
</style>
